package hn.sigit.model.ladm.spatialunit;

import java.io.Serializable;
import javax.persistence.*;


@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="LA_RequiredRelationshipSpatialUnit", schema="ladm_spatialunit")
@Inheritance(strategy=InheritanceType.JOINED)
//@DiscriminatorValue("LA_RequiredRelationship")
@IdClass(LA_RequiredRelationshipSpatialUnitPK.class)
public class LA_RequiredRelationshipSpatialUnit extends hn.sigit.model.ladm.special.VersionedObject implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private long spatialUnit1Id;
	private long spatialUnit2Id;
	private LA_SpatialUnit spatialUnit1;
	private LA_SpatialUnit spatialUnit2;
	private ISO19125_Type relationship;


	public LA_RequiredRelationshipSpatialUnit() {
	}

	@Id
	@Column(name="LA_SpatialUnitID", nullable=false, insertable=false, updatable=false)
	//@GeneratedValue(generator="la_requiredrelationshipspatialunit_id_gen")
	//@org.hibernate.annotations.GenericGenerator(name="la_requiredrelationshipspatialunit_id_gen", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name="property", value="Id"))
	public long getSpatialUnit1Id() {
		return spatialUnit1Id;
	}
	public void setSpatialUnit1Id(long value) {
		this.spatialUnit1Id = value;
	}
	
	@Id
	@Column(name="LA_SpatialUnitID2", nullable=false, insertable=false, updatable=false)
	//@GeneratedValue(generator="la_requiredrelationshipspatialunit_id_gen2")
	//@org.hibernate.annotations.GenericGenerator(name="la_requiredrelationshipspatialunit_id_gen2", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name="property", value="Id"))
	public long getSpatialUnit2Id() {
		return spatialUnit2Id;
	}
	public void setSpatialUnit2Id(long value) {
		this.spatialUnit2Id = value;
	}
	
	
	@PrimaryKeyJoinColumn
	@ManyToOne(targetEntity=LA_SpatialUnit.class)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})
	@JoinColumns({ @JoinColumn(name="LA_SpatialUnitID", referencedColumnName="ID") })
	public LA_SpatialUnit getSpatialUnit1() {
		return spatialUnit1;
	}
	public void setSpatialUnit1(LA_SpatialUnit value) {
		this.spatialUnit1 = value;
	}

	@PrimaryKeyJoinColumn
	@ManyToOne(targetEntity=LA_SpatialUnit.class)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})
	@JoinColumns({ @JoinColumn(name="LA_SpatialUnitID2", referencedColumnName="ID") })
	public LA_SpatialUnit getSpatialUnit2() {
		return spatialUnit2;
	}
	public void setSpatialUnit2(LA_SpatialUnit value) {
		this.spatialUnit2 = value;
	}
	
	@Column(name="Relationship", nullable=false)
	public ISO19125_Type getRelationship() {
		return relationship;
	}
	public void setRelationship(ISO19125_Type value) {
		this.relationship = value;
	}

	/*
	public boolean equals(Object aObj) {
		if (aObj == this)
			return true;
		if (!(aObj instanceof LA_RequiredRelationshipSpatialUnit))
			return false;
		LA_RequiredRelationshipSpatialUnit la_requiredrelationshipspatialunit = (LA_RequiredRelationshipSpatialUnit)aObj;
		if (getSpatialUnit1() == null) {
			if (la_requiredrelationshipspatialunit.getSpatialUnit1() != null)
				return false;
		}
		else if (!getSpatialUnit1().equals(la_requiredrelationshipspatialunit.getSpatialUnit1()))
			return false;
		if (getSpatialUnit2() == null) {
			if (la_requiredrelationshipspatialunit.getSpatialUnit2() != null)
				return false;
		}
		else if (!getSpatialUnit2().equals(la_requiredrelationshipspatialunit.getSpatialUnit2()))
			return false;
		return true;
	}
	
	public int hashCode() {
		int hashcode = 0;
		if (getSpatialUnit1() != null) {
			hashcode = hashcode + (int) getSpatialUnit1().getORMID();
		}
		if (getSpatialUnit2() != null) {
			hashcode = hashcode + (int) getSpatialUnit2().getORMID();
		}
		return hashcode;
	}
	
	public String toString() {
		return super.toString();
	}
	*/
}
